<template>
  <div class="BookShelf">
    <div class="header">
      <div class="left">
        <span class="readTime">今日已读<i>0</i>分钟</span>
        <span class="login">登录同步</span>
      </div>
      <div class="right">
        <button>
          <img src="../../assets/images/gold.png" alt="">
          领钱
        </button>
        <van-icon name="search" />
        <van-icon name="underway-o" />
        <van-icon name="weapp-nav" />
      </div>
    </div>
    <div class="books" v-if="user && user.bookshelf.length>0">
      <book-shelf-card v-for="(item,index) in user.bookshelf" :item="item" :key="index"></book-shelf-card>
    </div>
    <!-- 无书本显示 -->
    <div class="notBook" v-if="!user||user.bookshelf.length<=0">
      <img src="../../assets/images/yang.png" alt="">
      <button>添加喜欢的小说</button>
    </div>
  </div>
</template>

<script>
import BookShelfCard from "./BookShelfCard"
import {mapState} from "vuex"
export default {
  components:{
    BookShelfCard,
  },
  data() {
    return {
      
    }
  },
  computed:{
    ...mapState(['user']),
  },
  created(){
    // console.log(this.user);
  }
}
</script>

<style lang="less">
.BookShelf{
  .header{
    display: flex;
    padding: 18px 16px;
    justify-content: space-between;
    align-items: center;
    .left{
      .readTime{
        font-size: 14px;
        i{
          display: inline-block;
          transform: scaleY(2) scaleX(2);
          margin: 0 7px;
          vertical-align: text-top;
          color: #FC3947;
          font-weight: 600;
          line-height: 10px;
        }
      }
      .login{
        background: #FCEAE6;
        color: #dd3936;
        padding: 5px 7px;
        border-radius: 20px;
        margin-left: 7px;
        vertical-align: top;
        line-height: 14px;
        position: relative;
        &:after{
          content: "";
          position: absolute;
          left: -8px;
          top: 0;
          bottom: 0;
          margin: auto;
          height: 0;
          width: 0;
          border: 4px solid transparent;
          border-right-color: #FCEAE6;
          border-right-width: 8px;
        }
      }
    }
    .right{
      display: flex;
      justify-content: space-between;
      align-items: center;
      button{
        background: #F0434A;
        border-radius: 20px;
        padding: 0px 7px;
        height: 23px;
        color: white;
        position: relative;
        line-height: 23px;
        img{
          // position: absolute;
          // bottom: 5px;
          width: 23px;
          margin-top: -12px;
        }
      }
      .van-icon{
        font-size: 20px;
        font-weight: 600;
        margin-left: 9px;
      }
    }
  }

  // 无书本显示
  .notBook{
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    display: grid;
    place-content: center;
    button{
      margin-top: 15px;
      font-size: 14px;
      padding: 12px 17px;
      background: #F24644;
      color: white;
      border-radius: 20px;
    }
  }
}
</style>